﻿namespace Tool.Utils
{
    public static class StringExtension
    {
        public static bool IsBlank(this string? str)
        {
            return string.IsNullOrWhiteSpace(str);
        }

        public static string ToPascalCase(this string str)
        {
            if (string.IsNullOrEmpty(str))
            {
                return str;
            }
            // Split the string into words based on spaces and underscores
            var words = str.Split(new[] { ' ', '_' }, StringSplitOptions.RemoveEmptyEntries);
            // Capitalize the first letter of each word and concatenate them
            return string.Concat(words.Select(word => char.ToUpperInvariant(word[0]) + word.Substring(1).ToLowerInvariant()));
        }
    }
}
